import React, { Component } from 'react';
import './App.css';
import Config from './config'

class App extends Component {
  constructor(props) {
    super(props)
    this.state = {
      width: document.querySelector('body').offsetWidth,
      height: document.querySelector('body').offsetHeight,
    }
  }

  componentDidMount() {
    let code = localStorage.getItem('code')
    if(code){
      this.props.history.push(`/SellTicket`)
    }else{
       this.getCode()
    }
  }

  getCode(){
    //snsapi_base  snsapi_userinfo 第一步用户授权，跳转目标页，在下一页得到code
    let redirect_urls= encodeURIComponent("https://www.stswat.com/sellTicket/wechat/#/SellTicket")
    let urls =  `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${Config.WeiXin.AppId}&redirect_uri=${redirect_urls}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`
    window.location.href = urls
  }

  render() {
    return (
      <div className="App" >

      </div>
    );
  }
}

export default App;
